<template>
    <view>
        <u-tabbar
                :value="current"
                @change="change"
                :fixed="true"
                :placeholder="true"
                :safeAreaInsetBottom="true"
        >
            <u-tabbar-item v-for="(item,index) in lists" :text="item.title" :icon="item.icon" :key="index"></u-tabbar-item>
        </u-tabbar>
    </view>
</template>

<script>
    export default {
        name: "bottom-navigation-bar",
        data() {
            return {
                current: parseInt(uni.getStorageSync('user_tab_bar')),
                lists: [{
                        title: '首页',
                        icon: 'home',
                        url: '/pages/user/index/index'
                    }, {
                        title: '心愿单',
                        icon: 'photo',
                        url: '/pages/user/wish/index'
                    }, {
                        title: '消息',
                        icon: 'play-right',
                        url: '/pages/user/message/index'
                    }, {
                        title: '我的',
                        icon: 'account',
                        url: '/pages/user/my/index'
                    }]
            };
        },
        methods: {
            change(index){
                uni.setStorageSync('user_tab_bar', index);
                // this.current = uni.getStorageSync('user_tab_bar');
                let url = this.lists[index].url;
                uni.switchTab({url: url});
            }
        }
    }
</script>

<style scoped>

</style>